package com.hmdp.core.controller;


import com.hmdp.core.service.IVoucherOrderService;
import com.hmdp.entity.dto.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@Api(tags = "抢卷模块")
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Autowired
    private IVoucherOrderService voucherOrderService;

    @ApiOperation("秒杀下单")
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
//        return voucherOrderService.seckillVoucher(voucherId);
        return voucherOrderService.seckillVoucherAsynchronousByJVM(voucherId);
        /**
         * 要使用这个记得现在redis控制台执行：xgroup create stream.orders g1 0 mkstream
         */
//        return voucherOrderService.seckillVouvherAsynchronousByRedisStream(voucherId);
    }
}
